import java.util.Scanner;

/**
 * xht
 */
public class GuessNumber {
    public static void main(String[] args) {
        while (true) {
            int xht1 = (int) (Math.random() * 100 + 1);
            Scanner scan = new Scanner(System.in);
            int xht2 = 0;
            int xht3 = 0;
            while (xht3 < 7) {
                System.out.println("请输入一个1-100之间的数字：");
                xht2 = scan.nextInt();
                xht3 = xht3 + 1;
                if (xht2 < xht1) {
                    System.out.println("小了！");
                    System.out.println("当前次数是第：" + xht3 + "次");
                } else if (xht2 > xht1) {
                    System.out.println("大了！");
                    System.out.println("当前次数是第：" + xht3 + "次");
                } else {
                    System.out.println("恭喜你答对了！ ");
                    break;
                }
            }
            if (xht3 == 7 && xht1 != xht2) {
                System.out.println("可惜啦！ 次数用完了！");
            }
            System.out.println("再来一轮吗?  (y/n): ");
            String choice = scan.next();
            if (!choice.equalsIgnoreCase("y")) {
                break;
            }
        }
    }
}
